//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.web.controller.sys;

import com.aidong.dao.wills.SysUserDao;
import com.aidong.model.wills.SysUser;
import com.aidong.web.controller.BaseController;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"chgpwd"})
public class ChgpwdController extends BaseController {
    @Resource
    SysUserDao sysUserDao;

    public ChgpwdController() {
    }

    @RequestMapping({"edit"})
    public ModelAndView edit() {
        return new ModelAndView("sys/chgpwd/edit");
    }

    @RequestMapping({"_edit"})
    @ResponseBody
    public String _edit(@RequestParam("oldPwd") String oldPwd, @RequestParam("password") String password) {
        SysUser user = (SysUser)this.sysUserDao.getById(this.getLoginUserCode());
        if(!this.getEncodePwd(user.getUserCode(), oldPwd).equals(user.getPassword())) {
            return this.getResult(false, "旧密码错误");
        } else {
            try {
                this.sysUserDao.updatePassword(user.getUserCode(), this.getEncodePwd(user.getUserCode(), password));
            } catch (Exception var5) {
                this.log.error("chgpwd", var5);
                return this.getResult(false, "发生错误");
            }

            return this.getResult(true, "修改成功");
        }
    }
}
